﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MDM.GUI.MDM.DataAccess;
using System.Collections;
using MDM.GUI.MDM.DataObjects;

namespace MDM.GUI.MDM.Business
{
    class UserController
    {

        public static void LoadUser()
        {
            UserIO.LoadUser();
        }
        public static int ValidateUser(string sUserName, string sPassword)
        {

            foreach (UserInfor itemUser in Common.aUserInfor )
            {
                if (itemUser.Name == sUserName && itemUser.Password == sPassword)
                {
                    return 1;
                }
                if (itemUser.Name == sUserName && itemUser.Password != sPassword)
                {
                    return 2;
                }
            }
            return 3;
        }

        /*
        static Hashtable hUserList;
>>>>>>> .r16
        public static bool checkUser(string sUserName, string sPassword)
        {
<<<<<<< .mine
            UserList = UserIO.getUsers();
            if (UserList.ContainsKey(UserName))
=======
            //ktra do dai user va do dai password
            //dung ktra tiep
            //sai tra ra false

            if (sUserName.Length < 50 && sUserName.Length > 6 && sPassword.Length < 50 && sPassword.Length > 6)
>>>>>>> .r15
            {
<<<<<<< .mine
<<<<<<< .mine

                string pass = UserList[UserName].ToString();
                if (pass == Password)
                    return true;
=======
=======

>>>>>>> .r16
                hUserList = UserIO.getUsers();
                //ktra ten user dang nhap co ten trong Login.txt hay khong
                //dung ktra tiep
                //sai tra ra false
                if (hUserList.ContainsKey(sUserName))
                {
                    //lay pass trong Login.txt dua theo ten do
                    string sPasswordInLogin = hUserList[sUserName].ToString();
                    //ktra pass nhap vao co dung voi pass trong Login hay k
                    //dung tra ra true
                    //sai tra ra false
                    if (sPasswordInLogin == sPassword)
                        return true;
                    else
                        return false;
                }
>>>>>>> .r15
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
        */
    }
}
